/**
 *  echarts 样式重置
 *  params  color  string
 *  params  size   string
 *
 * */
function resetStyle(color, size) {
    return {
        color: color,
        fontSize: size,
    }
}

//数据内容
var dataObj = {
    drugstore: 0,//药店
    medicalEstablishment: 0,//医疗机构
    drugstoreRatio: 0,//药店比例
    newDrugstore: [3630, 5070, 7100, 10000, 14000],//最近六年电商农产品销售额
}

//数据操作
var dataFun = {
    init() {
        this.optsDisPie();
        this.leafletMap();
    },
    optsDisPie() {
        dataObj.drugstore = parseInt(Math.random() * 1000);
        dataObj.medicalEstablishment = 1000 - dataObj.drugstore;
        dataObj.drugstoreRatio = (dataObj.drugstore / 1000 * 100).toFixed(1);
    },
    //地图
    leafletMap() {

    }
}
dataFun.init();

// 显示 农产品基地 和 电商数量 的比例分布
var optsDisPie = {
    title: {
        text: '销售区域分布',
        padding: 5,
        left: 'center',
        textStyle: resetStyle("#838188", '110%')
    },
    // '#3398DB', '#e06711', '#00dca5', '#ffcf00',
    color: ['#ffcf00', '#e06711', '#00dca5', '#3398DB'],
    tooltip: {
        show: false,
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'horizontal',
        x: 'center',
        bottom: 10,
        data: ['省内', '上海', '江苏', '其他'],
        selectedMode: false,
        textStyle: resetStyle("#889cbb", '90%')
    },
    series: [
        {
            name: '',
            type: 'pie',
            radius: ['40%', '60%'],
            avoidLabelOverlap: false,
            hoverAnimation: false,
            silent: false,
            label: {
                normal: {
                    show: true,
                    position: 'center',
                    formatter: function (parmars, ticket, callback) {

                        // return `总人才()\n   200人 `
                        return `省内(${50}%)`
                    },
                    textStyle: resetStyle("#fff", '100%')
                },
                emphasis: {
                    show: false,
                }
            },
            labelLine: {
                normal: {
                    show: true
                }
            },
            data: [
                {value: 50, name: '省内'},
                {value: 20, name: '上海'},
                {value: 15, name: '江苏'},
                {value: 15, name: '其他'}
            ]
        }
    ]
};


// 淘宝、京东、微信、拼多多、其他    这些平台销售的商家数量
var optsDisBar = {
        color: ['#3398DB'],
        title: {
            text: '平台商家数量',
            padding: 5,
            left: 'left',
            subtext: '单位（家）',
            textStyle: resetStyle("#fff", '100%')
        },
        grid: {
            left: '-35',
            right: '0',
            bottom: '10',
            top: "50",
            containLabel: true
        },
        tooltip: {
            trigger: 'item'
            // trigger: 'axis',
            // axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            //     type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            // }
        },
        xAxis: {
            data: ['微信', '淘宝', '京东', '拼多多', '其他'],
            // data: ['1', '2', '3', '4', '5'],

            axisTick:
                {
                    show: true
                }
            ,

            axisLabel: {
                fontSize: "80%",
                formatter:

                    function (params) {
                        var newParamsName = "";
                        var paramsNameNumber = params.length;
                        var provideNumber = 5;  //一行显示几个字
                        var rowNumber = Math.ceil(paramsNameNumber / provideNumber);
                        if (paramsNameNumber > provideNumber) {
                            for (var p = 0; p < rowNumber; p++) {
                                var tempStr = "";
                                var start = p * provideNumber;
                                var end = start + provideNumber;
                                if (p == rowNumber - 1) {
                                    tempStr = params.substring(start, paramsNameNumber);
                                } else {
                                    tempStr = params.substring(start, end) + "\n";
                                }
                                newParamsName += tempStr;
                            }

                        } else {
                            newParamsName = params;
                        }
                        return newParamsName
                    }

                ,
            }
            ,
            axisLine: {
                lineStyle: {
                    color: "#00c0ff" // 2b83eb
                }
                ,
            }
            ,

        }
        ,
        yAxis: {

            show: false,
            type:
                'value',
            axisTick:
                {
                    alignWithLabel: true
                }
            ,
            axisLine: {
                lineStyle: {
                    color: "#ddd",
                    width: 1
                }
            }
        }
        ,
        dataZoom: [
            {
                type: 'inside'
            }
        ],
        series:
            [
                {
                    type: 'bar',
                    itemStyle: {
                        normal: {color: '#1c3e60'}
                    },
                    tooltip: {
                        return: ""
                        // // formatter: " {a}<br/>&nbsp;&nbsp;&nbsp;{b}"+skyValueArr[0],
                        // backgroundColor: 'rgba(255, 255, 255, 0.7)',
                        // textStyle: {
                        //     // color: '#000',
                        //     fontSize: "90%"
                        // }
                    },
                    barGap: '-100%',
                    barCategoryGap: '60%',
                    data: [657, 657, 657, 657, 657],
                    animation: false
                },
                {
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 1,
                                [
                                    {offset: 0, color: '#055282'},
                                    {offset: 0.5, color: '#00a3c3'},
                                    {offset: 1, color: '#00d5e0'}
                                ]
                            )
                        },
                        // emphasis: {
                        //     color: new echarts.graphic.LinearGradient(
                        //         0, 0, 0, 1,
                        //         [
                        //             {offset: 0, color: '#2378f7'},
                        //             {offset: 0.7, color: '#2378f7'},
                        //             {offset: 1, color: '#83bff6'}
                        //         ]
                        //     )
                        // }
                    },
                    label: {
                        normal: {
                            show: true,
                            position: 'inside'
                        }
                    },
                    tooltip: {
                        // formatter: " {a}<br/>&nbsp;&nbsp;&nbsp;{b}"+skyValueArr[0],
                        backgroundColor: 'rgba(255, 255, 255, 0.7)',
                        textStyle: {
                            // color: '#000',
                            fontSize: "90%"
                        }
                    },
                    markPoint: {
                        data: [
                            // {type: 'max', name: '最大值'},
                            // {type: 'min', name: '最小值'}
                            // {name: "最大值", valueIndex : 0, type: 'max'},
                            // {name: "最小值", type: 'min', valueIndex : 1},
                        ],
                    },
                    // markLine: {
                    //     data: [
                    //         {type: 'average', name: '平均值'}
                    //     ]
                    // },
                    data: [362, 132, 66, 32, 65]
                }
            ]
    }
;

// 右侧 近五年 电商农产品销售额
var optsRightBar1 = {
    title: {
        text: '最近五年电商农产品销售额',
        padding: 5,
        left: 'left',
        subtext: '单位（万元）',
        textStyle: resetStyle("#fff", '100%')
    },
    color: ['#3398DB', "green"],
    tooltip: {
        trigger: 'item',
        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },
    grid: {
        left: '-50',
        right: '-40',
        bottom: '10',
        top: "20",
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            boundaryGap: true,
            axisLine: {
                lineStyle: {
                    color: "#00c0ff",
                    width: 1
                }
            },
            axisLabel: {
                fontSize: "80%"
            },
            // name: '年',
            data: ['2014', '2015', '2016', '2017', '2018']
        },
        {
            type: 'category',
            show: false,
            axisLine: {
                lineStyle: {
                    color: "#00c0ff",
                    width: 1
                }
            },
            // name: '年',
            boundaryGap: true,
            data: ['2014', '2015', '2016', '2017', '2018']
        }
    ],
    yAxis: [
        {
            type: 'value',
            show: false,
            // scale: true,
            name: '销售额',
            min: 0,
            axisLine: {
                lineStyle: {
                    color: "#4f4e73",
                    width: 1
                }
            },
            tooltip: {
                // formatter: " {a}<br/>&nbsp;&nbsp;&nbsp;{b}"+skyValueArr[0],
                backgroundColor: 'rgba(255, 255, 255, 0.7)',
                textStyle: {
                    // color: '#000',
                    fontSize: "90%"
                }
            },
            splitLine: {
                show: false
            },
            boundaryGap: [0, 0]
        },
        {
            show: false,
            type: 'value',
            // scale: true,
            tooltip: {
                // formatter: " {a}<br/>&nbsp;&nbsp;&nbsp;{b}"+skyValueArr[0],
                backgroundColor: 'rgba(255, 255, 255, 0.7)',
                textStyle: {
                    // color: '#000',
                    fontSize: "90%"
                }
            },
            axisLine: {
                lineStyle: {
                    color: "#ddd",
                    width: 1
                }
            },
            min: 0,
            name: '销售额',
            boundaryGap: [0, 0]
        }
    ],
    series: [
        {
            name: '新开药店数量',
            type: 'line',
            smooth: true,
            lineStyle: {
                normal: {
                    color: '#00dda4'
                }
            },
            markPoint: {
                data: [
                    // {type: 'max', name: '最大值'},
                    // {type: 'min', name: '最小值'}
                ]
            },
            splitLine: {
                show: false
            },
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: '#152851'
                    }, {
                        offset: 1,
                        color: '#00b6cc'
                    }])
                }
            },
            data: dataObj.newDrugstore
        },
        {
            name: '电商农产品销售额',
            type: 'bar',
            xAxisIndex: 1,
            yAxisIndex: 1,
            barWidth: '50%',
            label: {
                normal: {
                    show: true,
                    position: 'inside',
                    formatter: function (parmars) {
                        // console.log(parmars);
                        var str = parmars.value + ""//单位
                        return str
                    }
                }
            },
            itemStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: '#03fbe4'},
                            {offset: 0.5, color: '#1dd2e7'},
                            {offset: 1, color: '#419aec'}
                        ]
                    )
                },
            },
            // markLine: {
            //     data: [
            //         {type: 'average', name: '平均值'}
            //     ]
            // },
            data: dataObj.newDrugstore
        },
    ]
}


//  项目金额销售和纳税
var posList = [
    'left', 'right', 'top', 'bottom',
    'inside',
    'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
    'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
];
var app = {}
app.configParameters = {
    rotate: {
        min: -90,
        max: 90
    },
    align: {
        options: {
            left: 'left',
            center: 'center',
            right: 'right'
        }
    },
    verticalAlign: {
        options: {
            top: 'top',
            middle: 'middle',
            bottom: 'bottom'
        }
    },
    position: {
        options: echarts.util.reduce(posList, function (map, pos) {
            map[pos] = pos;
            return map;
        }, {})
    },
    distance: {
        min: 0,
        max: 100
    }
};
app.config = {
    rotate: 90,
    align: 'left',
    verticalAlign: 'middle',
    position: 'insideBottom',
    distance: 15,

};
var labelOption = {
    normal: {
        show: true,
        fontSize: "80%",
        position: app.config.position,
        distance: app.config.distance,
        align: app.config.align,
        verticalAlign: app.config.verticalAlign,
        rotate: app.config.rotate,
        // formatter: '{c}  {name|{a}}',
        formatter: '{c}' + " 万元",
        rich: {
            name: {
                textBorderColor: '#fff'
            }
        }
    }
};

// 农产品线下销售额 和 农产品线上销售额
var optsBottomDbar = {
    color: ['#63c982', '#ff9a00'],
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        }
    },
    legend: {
        data: ['农产品线下销售额', '农产品线上销售额'],
        left: 'left',
        itemGap: 40,
        textStyle: resetStyle("#889cbb", '90%')
    },
    calculable: true,
    grid: {
        left: '10',
        right: '0',
        bottom: '10',
        top: "30",
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            axisTick: {show: false},
            axisLine: {
                lineStyle: {
                    color: "#2b83eb",
                    width: 1
                }
            },
            axisLabel: {
                fontSize: "80%"
            },
            data: ['2014', '2015', '2016', '2017', '2018']
        }
    ],
    yAxis: [
        {
            type: 'value',
            // name: '万元',
            axisLine: {
                lineStyle: {
                    color: "#ddd",
                    width: 1
                }
            },
            splitLine: {
                show: false
            },
            axisLabel: {
                fontSize: "80%"
            },
        }
    ],
    series: [
        {
            name: '农产品线下销售额',
            type: 'bar',
            barGap: 0,
            label: labelOption,
            data: [2541, 2535, 2840, 3000, 2100]
        },
        {
            name: '农产品线上销售额',
            type: 'bar',
            barMinHeight: 4,
            label: labelOption,
            data: [1089, 2535, 4260, 7000, 11900]
        }
    ]
};


// 底部图  客户产品满意度
var optsButtomAdd = {
    color: ['#3398DB', '#e06711', '#00dca5', '#ffcf00', '#ffffff', '#5CACEE', '#8B7E66', '#F5DEB3', '#FFB5C5', '#8B658B'],
    title: {
        show: true,
        text: '客户产品满意度',
        padding: 5,
        left: 'center',
        textStyle: resetStyle("#838188", '110%')
    },
    tooltip: {
        trigger: 'item',
        // formatter: "{a} <br/>{b} : {c}件 ({d}%)"
        formatter: "{a} <br/>{b} : {d}%"
    },
    legend: {
        orient: 'vertical',
        left: 'right',
        right: 0,   //右邊距
        textStyle: resetStyle("#889cbb", '90%'),
        data: ['非常满意', '满意', '一般', '不满意']
    },
    series: [
        {
            name: '客户产品满意度',
            type: 'pie',
            radius: '55%',
            center: ['40%', '60%'],
            data: [
                {value: 80, name: '非常满意'},
                {value: 15, name: '满意'},
                {value: 3, name: '一般'},
                {value: 2, name: '不满意'}
            ],
            label: {
                normal: {
                    // formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                    formatter: ' {b|{b}：} {c}%',
                    backgroundColor: 'transparent',
                    borderColor: '#aaa',
                    // borderWidth: 1,
                    // borderRadius: 4,
                    rich: {
                        a: {
                            color: '#999',
                            align: 'center'
                        },
                        hr: {
                            borderColor: 'transparent',
                            // width: '100%',
                            // borderWidth: 0.5,
                            height: 0
                        },
                        b: {
                            fontSize: "80%",
                            lineHeight: 33
                        },
                        per: {
                            color: '#eee',
                            backgroundColor: 'transparent',
                            borderRadius: 2
                        }
                    }
                }
            },
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 20,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
}

// 各年度”电商”总数量
var optsButtomPerson = {
    color: ["#e06711"],
    title: {
        show: false,
        text: '各年度电商数量',
        padding: 5,
        left: 'left',
        subtext: '（家）',
        textStyle: resetStyle("#fff", '100%')
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        // show: false
        left: 'left',
        textStyle: resetStyle("#889cbb", '90%'),
        // width: 370,
        itemGap: 40,
        data: ['电商数量(家)']
    },
    grid: {
        left: '3%',
        // right: '4%',
        bottom: '3%',
        top: 30,
        containLabel: true
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        axisLine: {
            lineStyle: {
                color: "#2b83eb",
                width: 1
            }
        },
        axisLabel: {
            fontSize: "80%"
        },
        data: ['2014', '2015', '2016', '2017', '2018']
    },
    yAxis: {
        type: 'value',
        axisLine: {
            lineStyle: {
                color: "#ddd",
                width: 1
            }
        },
        splitLine: false,
        axisLabel: {
            fontSize: "80%"
        },
    },
    series: [
        {
            name: '电商数量(家)',
            type: 'line',
            smooth: true,
            stack: '总量',
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: '#152851'
                    }, {
                        offset: 1,
                        color: '#00b6cc'
                    }])
                }
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            },
            data: [156, 214, 320, 520, 657]
        }
    ]
}

// 主要产品销售占比
var optsButtomCountry = {
    color: ['#3398DB', '#e06711', '#00dca5', '#ffcf00', '#ffffff', '#5CACEE', '#8B7E66', '#F5DEB3', '#FFB5C5', '#8B658B'],
    title: {
        show: true,
        text: '主要产品销售占比',
        padding: 5,
        left: 'center',
        textStyle: resetStyle("#838188", '110%')
    },
    tooltip: {
        trigger: 'item',
        // formatter: "{a} <br/>{b} : {c}件 ({d}%)"
        formatter: "{a} <br/>{b} : {d}%"
    },
    legend: {
        orient: 'vertical',
        left: 'right',
        right: 0,   //右邊距
        textStyle: resetStyle("#889cbb", '90%'),
        data: ['山核桃', '茶叶', '手工糕点', '农家酱', '活鱼打包', '地瓜干', '其他']
    },
    series: [
        {
            name: '销售占比',
            type: 'pie',
            radius: '55%',
            center: ['40%', '60%'],
            data: [
                {value: 23, name: '山核桃'},
                {value: 18, name: '茶叶'},
                {value: 15, name: '手工糕点'},
                {value: 12, name: '农家酱'},
                {value: 6, name: '活鱼打包'},
                {value: 6, name: '地瓜干'},
                {value: 20, name: '其他'},
            ],
            label: {
                normal: {
                    // formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                    formatter: ' {b|{b}：} {c}%',
                    backgroundColor: 'transparent',
                    borderColor: '#aaa',
                    // borderWidth: 1,
                    // borderRadius: 4,
                    rich: {
                        a: {
                            color: '#999',
                            align: 'center'
                        },
                        hr: {
                            borderColor: 'transparent',
                            // width: '100%',
                            // borderWidth: 0.5,
                            height: 0
                        },
                        b: {
                            fontSize: "80%",
                            lineHeight: 33
                        },
                        per: {
                            color: '#eee',
                            backgroundColor: 'transparent',
                            borderRadius: 2
                        }
                    }
                }
            },
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 20,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};

// 雷达图  主要产品销售渠道
var optsRadar = {
    color: ['#e06711', '#2eddcd', '#e06711', '#ffcf00', '#ffffff'],
    title: {
        show: true,
        text: '主要产品销售渠道',
        padding: 0,
        left: 'left',
        textStyle: resetStyle("#889cbb", '100%')
    },
    tooltip: {
        // trigger: 'item',
        // formatter: "{a} <br/>{b} : {c}件 ({d}%)"
    },
    legend: {
        show: true,
        orient: 'vertical',
        left: 'right',
        textStyle: resetStyle("#889cbb", '90%'),
        data: ['线上销售数量']

    },
    grid: {
        left: '3%',
        // right: '4%',
        bottom: '3%',
        // top: 40,
        containLabel: true
    },
    radar: {
        // shape: 'circle',
        name: {
            textStyle: {
                color: '#fff',
                backgroundColor: '#999',
                borderRadius: 3,
                padding: [3, 5]
            }
        },
        radius: 50,
        indicator: [
            // {name: '海曙区', max: 100},笋干、鱼头、板栗、小核桃、番薯干
            {name: '山核桃'},
            {name: '茶叶'},
            {name: '手工糕点'},
            {name: '农家酱'},
            {name: '活鱼打包'},
            {name: '地瓜干'},
            {name: '其他'},
        ],
        center: ['50%', '60%'],
    },
    series: [{
        name: '主要产品销售数量',
        type: 'radar',
        // areaStyle: {normal: {}},
        data: [
            {
                value: [40, 30, 80, 80, 60, 80, 30],
                name: '线上销售数量'
            }
        ]
    }]
}

// 世界地图
var geoCoordMap = {
    '中国·诸暨': [119.5107, 29.7196],
    '美国': [-100.696295, 33.679979],
    '日本': [139.710164, 35.706962],
    '韩国': [126.979208, 37.53875],
    '乌克兰': [30.8719426, 48.8222422],
    '英国': [-3.435973, 55.378051],
    '德国': [10.451526, 51.165691],
    '西班牙': [-3.74922, 40.46366700000001],
};

// 诸暨
var GZData = [
    [{name: '中国·诸暨'}, {name: "日本", value: 30}],
    [{name: '中国·诸暨'}, {name: "美国", value: 30}],
    [{name: '中国·诸暨'}, {name: "韩国", value: 30}],
    [{name: '中国·诸暨'}, {name: "乌克兰", value: 30}],
    [{name: '中国·诸暨'}, {name: "英国", value: 30}],
    [{name: '中国·诸暨'}, {name: "德国", value: 30}],
    [{name: '中国·诸暨'}, {name: "西班牙", value: 30}],
];


// 小飞机的图标，可以用其他图形替换
var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';

// 获取地图中起点和终点的坐标，以数组形式保存下来
var convertData = function (data) {
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var dataItem = data[i];
        var fromCoord = geoCoordMap[dataItem[1].name];
        var toCoord = geoCoordMap[dataItem[0].name];
        if (fromCoord && toCoord) {
            res.push([{
                coord: fromCoord // 起点坐标
            }, {
                coord: toCoord // 终点坐标
            }])
        }
    }
    return res;
}

var color = ['#CDCD00', '#dcbf71', '#000'];
var series = [];

//在地图上显示各区药店数据
var mapData = [
    {name: '瑶山乡', value: 38},
    {name: '文昌镇', value: 50},
    {name: '里商乡', value: 24},
    {name: '安阳乡', value: 40},
    {name: '千岛湖镇', value: 18},
    {name: '中州镇', value: 35},
    {name: '宋村乡', value: 21},
    {name: '界首乡', value: 29},
    {name: '白马乡', value: 18},
    {name: '梓桐镇', value: 10}
];
var geoCoordMap = {
    '瑶山乡': [119.0752300000, 29.9013600000],
    '文昌镇': [119.3151800000, 29.7451000000],
    '里商乡': [119.0016700000, 29.4895800000],
    '安阳乡': [118.8718100000, 29.4418300000],
    '千岛湖镇': [119.1742800000, 29.6323100000],
    '中州镇': [118.4073800000, 29.4785800000],
    '宋村乡': [118.9120800000, 29.6940400000],
    '界首乡': [118.7945800000, 29.5840900000],
    '白马乡': [118.7193700000, 29.3226200000],
    '梓桐镇': [118.7620500000, 29.6361000000],
};
var convertData = function (data) {
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var geoCoord = geoCoordMap[data[i].name];
        if (geoCoord) {
            res.push({
                name: data[i].name,
                value: geoCoord.concat(data[i].value)
            });
        }
    }
    return res;
};

//纸飞机效果
// [['中国·诸暨', GZData]].forEach(function (item, i) {
//     series.push({
//         // 白色航线特效图
//         type: 'lines',
//         zlevel: 1,                    // 用于分层，z-index的效果
//         effect: {
//             show: true,               // 动效是否显示
//             period: 6,                // 特效动画时间
//             trailLength: 0.7,         // 特效尾迹的长度
//             color: '#fff',            // 特效颜色
//             symbolSize: 3             // 特效大小
//         },
//         lineStyle: {
//             normal: {                 // 正常情况下的线条样式
//                 color: color[0],
//                 width: 0,             // 因为是叠加效果，要是有宽度，线条会变粗，白色航线特效不明显
//                 curveness: -0.2       // 线条曲度
//             }
//         },
//         data: convertData(item[1])    // 特效的起始、终点位置
//     }, {  // 小飞机航线效果
//         type: 'lines',
//         zlevel: 2,
//         //symbol: ['none', 'arrow'],   // 用于设置箭头
//         symbolSize: 10,
//         effect: {
//             show: true,
//             period: 6,
//             trailLength: 0,
//             symbol: planePath,         // 特效形状，可以用其他svg pathdata路径代替
//             // symbolSize: "100%"
//             symbolSize: 3
//         },
//         lineStyle: {
//             normal: {
//                 color: color[0],
//                 width: 1,
//                 opacity: 0.6,
//                 curveness: -0.2
//             }
//         },
//         data: convertData(item[1])     // 特效的起始、终点位置，一个二维数组，相当于coords: convertData(item[1])
//     }, { // 散点效果
//         type: 'effectScatter',
//         coordinateSystem: 'geo',       // 表示使用的坐标系为地理坐标系
//         zlevel: 3,
//         rippleEffect: {
//             brushType: 'stroke'        // 波纹绘制效果
//         },
//         label: {
//             normal: {                  // 默认的文本标签显示样式
//                 show: true,
//                 position: 'left',      // 标签显示的位置
//                 formatter: '{b}'       // 标签内容格式器
//             }
//         },
//         itemStyle: {
//             normal: {
//                 color: color[0]
//             }
//         },
//         data: item[1].map(function (dataItem) {
//             return {
//                 name: dataItem[1].name,
//                 value: geoCoordMap[dataItem[1].name],  // 起点的位置
//                 symbolSize: dataItem[1].value / 8,  // 散点的大小，通过之前设置的权重来计算，val的值来自data返回的value
//             };
//         })
//     });
// });

series.push({
    name: '药店',
    type: 'effectScatter',
    coordinateSystem: 'geo',
    data: convertData(mapData),
    symbolSize: function (val) {
        return val[2] / 2;
    },
    showEffectOn: 'render',
    rippleEffect: {
        brushType: 'stroke'
    },
    hoverAnimation: true,
    label: {
        normal: {
            formatter: function (name) {
                return name.data.value[2];
            },
            position: 'right',
            show: true,
            textStyle: {

                color: 'green',
                fontSize: 14

            }
        }
    },
    itemStyle: {
        normal: {
            color: 'green',
            shadowBlur: 10,
            shadowColor: '#333'
        }
    },
    zlevel: 1
});

//宁波地区药店分布图
var mapsOpts = {
    title: {
        show: false,
        text: '宁波地区药店分布图',
        textStyle: {
            color: 'rgba(0,0,0,0)',
            fontSize: "100%"
        },
        top: '0px',
        left: '0px'
    },
    geo: {
        map: 'chunan',       // 与引用进来的地图js名字一致
        roam: false,        // 禁止缩放平移
        itemStyle: {        // 每个区域的样式
            normal: {
                areaColor: 'rgba(0,0,0,0)',
                color: "rgba(0,0,0,0)",
                borderColor: 'rgba(0,0,0,0)'
            },
            emphasis: {
                areaColor: 'rgba(0,0,0,0)',
                color: "rgba(0,0,0,0)"
            }
        },
        zoom: 1.3,
        regions: []
    },
    series: series,
    textStyle: {
        fontSize: "80%"
    }
}

// 初始化表
function initChart(id, opts) {
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById(id));
    myChart.setOption(opts);
    //
    return myChart
}
